package com.lnsystem.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;



@Entity
@Table(name="STOCK")
public class Stock {
        
        //TODO add more fields like volume, date, OHLC etc. Or may be create separate
        //classes for Daily, weekly and monthly data.. 
        
        @Id
        @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="STOCK_SEQUENCE")
        @SequenceGenerator(
                    name="STOCK_SEQUENCE",
                    sequenceName="STOCK_SEQUENCE",
                    allocationSize=20
                )
        int id;
        
        @Column(name="SYMBOL")
        String symbol;
        
        @Column(name="NAME")
        String name;
        
        @Column(name="INDEX")
        String index;
        
        @OneToMany(fetch = FetchType.LAZY, mappedBy = "stockId", cascade = {CascadeType.ALL})
        private List<StockDailyData> stockDailyData; 
        
        @OneToMany(fetch = FetchType.LAZY, mappedBy = "stockIdWeekly", cascade = {CascadeType.ALL})
        private List<StockWeeklyData> stockWeeklyData; 
        

    	@OneToOne(fetch = FetchType.LAZY, mappedBy = "stockId", cascade = CascadeType.ALL)
        private StockRating stockRating; 

        @OneToMany(fetch = FetchType.LAZY, mappedBy = "stockId", cascade = {CascadeType.ALL})
        private List<AnalyticsEvent> analyticsEvents;     	
    	
    	public StockRating getStockRating() {
    		return this.stockRating;
    	}
    	
        @Transient
        private List<StockDailyData> pocketPivots;
        
        @Transient
        private List<StockDailyData> smCross;
        
        @Transient
        private String healthString;
        
    	@Transient
    	private String notes;
    	
        public int getId() {
                return id;
        }
        public void setId(int id) {
                this.id = id;
        }
        public String getSymbol() {
                return symbol;
        }
        public void setSymbol(String symbol) {
                this.symbol = symbol;
        }
        public String getName() {
                return name;
        }
        public void setName(String name) {
                this.name = name;
        }
        public String getIndex() {
                return index;
        }
        public void setIndex(String index) {
                this.index = index;
        }
        
        public List<StockDailyData> getStockDailyData() {
                return stockDailyData;
        }
        public void setStockDailyData(List<StockDailyData> stockDailyData) {
                this.stockDailyData = stockDailyData;
        }
        
        public List<StockWeeklyData> getStockWeeklyData() {
			return stockWeeklyData;
		}
		public void setStockWeeklyData(List<StockWeeklyData> stockWeeklyData) {
			this.stockWeeklyData = stockWeeklyData;
		}
		public List<StockDailyData> getPocketPivots() {
			return pocketPivots;
		}
		public void setPocketPivots(List<StockDailyData> pocketPivots) {
			this.pocketPivots = pocketPivots;
		}
		public List<StockDailyData> getSmCross() {
			return smCross;
		}
		public void setSmCross(List<StockDailyData> smCross) {
			this.smCross = smCross;
		}
		
		public String getHealthString() {
			return healthString;
		}
		public void setHealthString(String healthString) {
			this.healthString = healthString;
		}
		@Override
        public String toString() {
                return "Stock [id=" + id + ", symbol=" + symbol + ", name=" + name
                                + ", index=" + index + "]";
        }
		public String getNotes() {
			return notes;
		}
		public void setNotes(String notes) {
			this.notes = notes;
		}
        
        
}